<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Calico: calico/optimization_utils.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Calico
   </div>
   <div id="projectbrief">A visual-inertial calibration library designed for rapid problem construction and debugging.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_e7ac338090e46d594d3ea7a0e9efc7ba.html">calico</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">optimization_utils.h</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#ifndef CALICO_OPTIMIZATION_UTILS_H_</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="preprocessor">#define CALICO_OPTIMIZATION_UTILS_H_</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160; </div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="preprocessor">#include &quot;calico/typedefs.h&quot;</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="preprocessor">#include &quot;ceres/ceres.h&quot;</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160; </div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160; </div>
<div class="line"><a name="l00009"></a><span class="lineno"><a class="line" href="namespacecalico_1_1utils.html">    9</a></span>&#160;<span class="keyword">namespace </span><a class="code" href="namespacecalico_1_1utils.html">calico::utils</a> {</div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160; </div>
<div class="line"><a name="l00015"></a><span class="lineno"><a class="line" href="namespacecalico_1_1utils.html#aacede3df540b75d2e131f113380f0ce9">   15</a></span>&#160;<span class="keyword">enum class</span> <a class="code" href="namespacecalico_1_1utils.html#aacede3df540b75d2e131f113380f0ce9">LossFunctionType</a> : int {</div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;  <a class="code" href="namespacecalico_1_1utils.html#aacede3df540b75d2e131f113380f0ce9a35c3ace1970663a16e5c65baa5941b13">kNone</a>,</div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;  <a class="code" href="namespacecalico_1_1utils.html#aacede3df540b75d2e131f113380f0ce9a084edafec56dd4f16e59c49086cd996b">kHuber</a>,</div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;  <a class="code" href="namespacecalico_1_1utils.html#aacede3df540b75d2e131f113380f0ce9a837525318a461e4a282986beb74c0211">kCauchy</a>,</div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;};</div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160; </div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160; </div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160; </div>
<div class="line"><a name="l00031"></a><span class="lineno"><a class="line" href="namespacecalico_1_1utils.html#aeee1e1f3baea4f1b75efab0c42923dcf">   31</a></span>&#160;<span class="keyword">inline</span> ceres::LossFunction* <a class="code" href="namespacecalico_1_1utils.html#aeee1e1f3baea4f1b75efab0c42923dcf">CreateLossFunction</a>(</div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;    <a class="code" href="namespacecalico_1_1utils.html#aacede3df540b75d2e131f113380f0ce9">LossFunctionType</a> loss, <span class="keywordtype">double</span> scale) {</div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;  <span class="keywordflow">switch</span> (loss) {</div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;    <span class="keywordflow">case</span> <a class="code" href="namespacecalico_1_1utils.html#aacede3df540b75d2e131f113380f0ce9a35c3ace1970663a16e5c65baa5941b13">LossFunctionType::kNone</a>: {</div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;      <span class="keywordflow">return</span> <span class="keyword">nullptr</span>;</div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;    }</div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;    <span class="keywordflow">case</span> <a class="code" href="namespacecalico_1_1utils.html#aacede3df540b75d2e131f113380f0ce9a084edafec56dd4f16e59c49086cd996b">LossFunctionType::kHuber</a>: {</div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;      <span class="keywordflow">return</span> <span class="keyword">new</span> ceres::HuberLoss(scale);</div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;    }</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;    <span class="keywordflow">case</span> <a class="code" href="namespacecalico_1_1utils.html#aacede3df540b75d2e131f113380f0ce9a837525318a461e4a282986beb74c0211">LossFunctionType::kCauchy</a>: {</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;      <span class="keywordflow">return</span> <span class="keyword">new</span> ceres::CauchyLoss(scale);</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;    }</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;    <span class="keywordflow">default</span>: {</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;      <span class="keywordflow">return</span> <span class="keyword">nullptr</span>;</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;    }</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;  }</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;}</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160; </div>
<div class="line"><a name="l00051"></a><span class="lineno"><a class="line" href="namespacecalico_1_1utils.html#ac4ef701716e2efff5e392c94bbb0e7ed">   51</a></span>&#160;<span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="namespacecalico_1_1utils.html#ac4ef701716e2efff5e392c94bbb0e7ed">AddPoseToProblem</a>(ceres::Problem&amp; problem, <a class="code" href="classcalico_1_1Pose3.html">Pose3d</a>&amp; pose) {</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;  <span class="keywordtype">int</span> num_parameters_added = 0;</div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;  problem.AddParameterBlock(pose.<a class="code" href="classcalico_1_1Pose3.html#a6199524fb9d92c656e8d9f63559c2708">translation</a>().data(),</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;                            pose.<a class="code" href="classcalico_1_1Pose3.html#a6199524fb9d92c656e8d9f63559c2708">translation</a>().size());</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;  num_parameters_added += pose.<a class="code" href="classcalico_1_1Pose3.html#a6199524fb9d92c656e8d9f63559c2708">translation</a>().size();</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;  ceres::Manifold* quat_manifold =  <span class="keyword">new</span> ceres::EigenQuaternionManifold;</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;  problem.AddParameterBlock(pose.<a class="code" href="classcalico_1_1Pose3.html#ab855f93c267acba1f5875b4668cded48">rotation</a>().coeffs().data(),</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;                            pose.<a class="code" href="classcalico_1_1Pose3.html#ab855f93c267acba1f5875b4668cded48">rotation</a>().coeffs().size(), quat_manifold);</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;  num_parameters_added += pose.<a class="code" href="classcalico_1_1Pose3.html#ab855f93c267acba1f5875b4668cded48">rotation</a>().coeffs().size();</div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;  <span class="keywordflow">return</span> num_parameters_added;</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;}</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160; </div>
<div class="line"><a name="l00065"></a><span class="lineno"><a class="line" href="namespacecalico_1_1utils.html#a86079fbae8165d8052d293a2cad53079">   65</a></span>&#160;<span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="namespacecalico_1_1utils.html#a86079fbae8165d8052d293a2cad53079">SetPoseConstantInProblem</a>(ceres::Problem&amp; problem, <a class="code" href="classcalico_1_1Pose3.html">Pose3d</a>&amp; pose) {</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;  problem.SetParameterBlockConstant(pose.<a class="code" href="classcalico_1_1Pose3.html#a6199524fb9d92c656e8d9f63559c2708">translation</a>().data());</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;  problem.SetParameterBlockConstant(pose.<a class="code" href="classcalico_1_1Pose3.html#ab855f93c267acba1f5875b4668cded48">rotation</a>().coeffs().data());</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;}</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160; </div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;} <span class="comment">// namespace calico</span></div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160; </div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;<span class="preprocessor">#endif </span><span class="comment">// CALICO_OPTIMIZATION_UTILS_H_</span></div>
<div class="ttc" id="aclasscalico_1_1Pose3_html"><div class="ttname"><a href="classcalico_1_1Pose3.html">calico::Pose3&lt; double &gt;</a></div></div>
<div class="ttc" id="aclasscalico_1_1Pose3_html_a6199524fb9d92c656e8d9f63559c2708"><div class="ttname"><a href="classcalico_1_1Pose3.html#a6199524fb9d92c656e8d9f63559c2708">calico::Pose3::translation</a></div><div class="ttdeci">Eigen::Vector3&lt; T &gt; &amp; translation()</div><div class="ttdoc">Translation accessor.</div><div class="ttdef"><b>Definition:</b> typedefs.h:60</div></div>
<div class="ttc" id="aclasscalico_1_1Pose3_html_ab855f93c267acba1f5875b4668cded48"><div class="ttname"><a href="classcalico_1_1Pose3.html#ab855f93c267acba1f5875b4668cded48">calico::Pose3::rotation</a></div><div class="ttdeci">Eigen::Quaternion&lt; T &gt; &amp; rotation()</div><div class="ttdoc">Rotation accessor.</div><div class="ttdef"><b>Definition:</b> typedefs.h:52</div></div>
<div class="ttc" id="anamespacecalico_1_1utils_html"><div class="ttname"><a href="namespacecalico_1_1utils.html">calico::utils</a></div><div class="ttdoc">Utils namespace.</div><div class="ttdef"><b>Definition:</b> optimization_utils.h:9</div></div>
<div class="ttc" id="anamespacecalico_1_1utils_html_a86079fbae8165d8052d293a2cad53079"><div class="ttname"><a href="namespacecalico_1_1utils.html#a86079fbae8165d8052d293a2cad53079">calico::utils::SetPoseConstantInProblem</a></div><div class="ttdeci">void SetPoseConstantInProblem(ceres::Problem &amp;problem, Pose3d &amp;pose)</div><div class="ttdef"><b>Definition:</b> optimization_utils.h:65</div></div>
<div class="ttc" id="anamespacecalico_1_1utils_html_aacede3df540b75d2e131f113380f0ce9"><div class="ttname"><a href="namespacecalico_1_1utils.html#aacede3df540b75d2e131f113380f0ce9">calico::utils::LossFunctionType</a></div><div class="ttdeci">LossFunctionType</div><div class="ttdef"><b>Definition:</b> optimization_utils.h:15</div></div>
<div class="ttc" id="anamespacecalico_1_1utils_html_aacede3df540b75d2e131f113380f0ce9a084edafec56dd4f16e59c49086cd996b"><div class="ttname"><a href="namespacecalico_1_1utils.html#aacede3df540b75d2e131f113380f0ce9a084edafec56dd4f16e59c49086cd996b">calico::utils::LossFunctionType::kHuber</a></div><div class="ttdeci">@ kHuber</div><div class="ttdoc">Huber loss.</div></div>
<div class="ttc" id="anamespacecalico_1_1utils_html_aacede3df540b75d2e131f113380f0ce9a35c3ace1970663a16e5c65baa5941b13"><div class="ttname"><a href="namespacecalico_1_1utils.html#aacede3df540b75d2e131f113380f0ce9a35c3ace1970663a16e5c65baa5941b13">calico::utils::LossFunctionType::kNone</a></div><div class="ttdeci">@ kNone</div><div class="ttdoc">Standard least-squares.</div></div>
<div class="ttc" id="anamespacecalico_1_1utils_html_aacede3df540b75d2e131f113380f0ce9a837525318a461e4a282986beb74c0211"><div class="ttname"><a href="namespacecalico_1_1utils.html#aacede3df540b75d2e131f113380f0ce9a837525318a461e4a282986beb74c0211">calico::utils::LossFunctionType::kCauchy</a></div><div class="ttdeci">@ kCauchy</div><div class="ttdoc">Cauchy loss.</div></div>
<div class="ttc" id="anamespacecalico_1_1utils_html_ac4ef701716e2efff5e392c94bbb0e7ed"><div class="ttname"><a href="namespacecalico_1_1utils.html#ac4ef701716e2efff5e392c94bbb0e7ed">calico::utils::AddPoseToProblem</a></div><div class="ttdeci">int AddPoseToProblem(ceres::Problem &amp;problem, Pose3d &amp;pose)</div><div class="ttdef"><b>Definition:</b> optimization_utils.h:51</div></div>
<div class="ttc" id="anamespacecalico_1_1utils_html_aeee1e1f3baea4f1b75efab0c42923dcf"><div class="ttname"><a href="namespacecalico_1_1utils.html#aeee1e1f3baea4f1b75efab0c42923dcf">calico::utils::CreateLossFunction</a></div><div class="ttdeci">ceres::LossFunction * CreateLossFunction(LossFunctionType loss, double scale)</div><div class="ttdef"><b>Definition:</b> optimization_utils.h:31</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1
</small></address>
</body>
</html>
